home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
126-150
/
disk_141
/
sbprolog
/
c_source.zoo
/
changes
next >
Wrap
Text File
|
1988-03-18
|
8KB
|
223 lines
Copyright 1988 by David A. Roch
.sp
Any or all of this document may be redistributed without
charge provided the above copyright notice is included.
.PP
This document (such as it is), describes a port of
Stony Brook Prolog (version 2.3.2) to a Commodore-Amiga
1000 microcomputer. I would also like to thank Scott
Evernden for allowing me to incorporate
changes he made in his port.
.PP
In my port, I never remove original code which will prevent
the system from running on UNIX (TM AT&T).
All of the changes that would prevent execution on a UNIX
box are accomplished by using pre\-processor conditional
branches. The symbol MICRO must then be defined at compile
time. Note that I have not changed the make files.
Also, pleas note that many of the MICRO changes are
specific to the Commodore-Amiga.
.PP
The Amiga operating system, currently does not support
environment variables other than assigning names to a
specific path (logical devices). Therefore, it was
necessary to add a new
flag to the simulator in order to pass the SIMPATH variable.
(See changes to file init.c).
Unfortunately, this makes SIMPATH static unless a new builtin
is added to change the path. I chose not to do this, as there
are rumors of AmigaDOS 1.3 possibly having environment vars.
Also, the getenv builtin (in file builtin/other.c) must
be changed to always return the SIMPATH. This is unfortunate,
but necessary as the run time read loop frequently requests the
value of SIMPATH. To the best of my knowledge, this is the only
environment variable the system ever requests. Finally, I changed
the seperator for directories in SIMPATH. UNIX uses
':' to separate paths, but as this indicates a logical device
name in AmigaDOS, I replaced it with '!'.
It can
easily be changed by setting the preprocessor symbol SEPARATOR
(file loader.c),
and the references to ':' in modlib/modlib_src/$readloop.P.
.PP
The following is a list of files and the changes I have made
to them.
.sp 3
File index.h
.PP
Sets the flag INDEX so that aux.h knows whether or not
to define indextab as an external.
.sp
File aux.h
.PP
If INDEX is defined, indextab becomes an external and the
indexing macros are not included (as they were defined in
index.h). Prior to this, indextab was defined in every
file (without being declared an external).
.sp
Files main.c
.PP
The routine call_sub should check for the interrupt
character. In Lattice C 4.0 for the Amiga, this
is done with the chkabort routine. (Thanks to Scott
Evernden).
.sp
File sub_inst.c
.PP
Interrupts must be changed for the microcomputer to which the
system is being ported. It is likely
that the sigvec (signal vector) does not exist. Therefore,
arm_intercept must be modified to set the interrupt signal.
.sp
File load.c
.PP
<stdio.h> commented out as it is already included in sim.h.
.sp
File loader.c
.PP
The colon ':' is no
longer hardcoded as the directory seperator for SIMPATH. It
is defined by the preprocessor label SEPERATOR. Also, the
character string simulation_path has been added to allow for the
new runtime option -i for systems without environment variables.
Some hacking was also necessary due to the different file
structure of Amiga DOS. Amiga DOS thus not support links, and
hence there is not a character for local directories ('.'). I
have solved this by invoking the loader on everything past the './'.
This works for the loader, but not all code. For example, the
$exists will fail for the query $exists('./some_file') even if
some_file does exist in the local directory.
Also, while UNIX (TM AT&T) uses '/' for the root directory,
Amiga DOS uses logical device names ending in a colon ':'. I
scan for the colon and invoke the loader if it is present.
The function call to getenv("SIMPATH") first checks if simulation_path
is non NULL. If simulation_path is non NULL, getenv is not invoked
and simulation_path is returned. Otherwise, getenv("SIMPATH") is
invoked.
Additionally, index.h is now
included here. There was no reference at all to this file previously.
.sp
File init.c
.PP
The modifications to this file permit the user to pass the -i SIMPATH
flag. An external reference to simulation_path has been added, and the
variable is originally set to NULL by init_sim. If the -i parameter
is present, the simulation_path is set by a switch statement. A case for
the i option must also be added in the procedures init_sym &
init_loading. This is to allow these procedure to strip out the -i
option when parsing the command line. Note that the case for 'i'
must be placed before the action to increment the loop variable.
This is necessary as i is followed by an argument.
.sp
File builtin/builtin.h
.PP
The references to a parent directories must be changed from '..' to '/'.
.sp
File builtin/file.c
.PP
The header file <netdb.h> has been set to compile only if flag MICRO
is undefined. Furthermore, the function b_GETHOSTBYNAME prints an
error message to standard out and calls fail0. Also, the include
<stdio.h> has been removed as it is already included in sim.h (which
is included in builtin.h).
.sp
File builtin/other.c
.PP
Include files <netdb.h>, <sys/socket.h>, <netinet/in.h>, and
<arpa/inet.h> all set to be included only if MICRO undefined.
Networking calls based on these (b_BROCALL with register R1
in the range of 21-46) are also compiled only if MICRO is
undefined. Finally,
the getenv call (R1 = 2) returns simulation_path whenever
simulation_path is non NULL. As simulation_path should only be
set when there are no environment variables, this should be an
acceptable change.
.sp
File builtin/time.c
.PP
The include file <sys/resource.h> has been changed to only be included
if MICRO is undefined as most micros don't have resource tracking.
The routines b_CPUTIME and b_STATISTICS have been modified to
get the Amiga CPU time (thanks Scott).
.sp
File builtin/saverest.c
.PP
Removed the include <stdio.h> as redundant, and changed the
name of <sys/file.h> to <fcntl.h> (Lattice C file control).
Also changed notation for including a parent file from '..'
to '/'. Finally, the numerous includes could probably be
replaced by one include to builtin.h
.sp
File modlib/modlib_src/$readloop.P
.PP
If the SEPARATOR character (see loader.c) is changed for the SIMPATH
environment variable (or equivalently, the new -i flag),
$readloop.P must be changed as it parses the SIMPATH variable.
Unfortunately, to recompile requires a working version of SBP.
This leaves the user with two alternatives:
.nf
1 - Make the change and compile on a working system
2 - Set up the simulator to work with the ':' as
SEPARATOR, make the change & recompile
$readloop.P, and finally recompile SBP
with the new SEPARATOR character.
.fi
.sp
NEW FILES:
.sp
sim/builtin/syscall.h
.PP
This is simply a recreation of the Berkely syscall.h
header file which is naturally not available on
non\-Berkely UNIX machines.
.sp
sim/builtin/syscall.c
.PP
This file contains one function which is designed to
emulate the Berkeley UNIX syscall function.
Assuming you do not wish to try to emulate sockets,
the only function I have found so far that is absolutely
necessary is the SYS_ACCESS function. Below is my
implementation for the Amiga.
.nf
/*
syscall.c by David Roch
This routine translates some of the Berkely Unix (tm)
system calls to the Amiga.
*/
#include <stdio.h>
#include "syscall.h"
syscall(n, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
int n;
call_args arg1, arg2, arg3, arg4, arg5, arg6, arg7;
{
switch (n) {
case SYS_chdir:
return(chdir(arg1));
case SYS_chmod:
return(chmod(arg1, arg2));
case SYS_access:
return(access(arg1, arg2));
default:
printf("System call %d has not yet been implemented in this port of SBProlog.\n",
"If you wish to add this system primitive, you must add the proper case\n",
"statement to the C source file syscall.c and recompile.\n");
return(-1); /* command failed (hopefully) */
}
}
.fi